<template>
  <div class="goods_pic">
    <img alt="" :src="picurl" />
  </div>
</template>

<script>
export default {
  name: "ToutiaoGoodspic",
  props: ["picid"],
  components: {},

  directives: {},

  data() {
    return {
      id: this.picid,
      picurl: "",
    };
  },

  mounted() {},
  created() {
    this.getPic(this.id, 1);
  },
  methods: {
    getPic(goodsId, type) {
      let that = this;
      $.ajax({
        type: "get",
        url: `http://121.4.40.144/api/photo/${goodsId}/${type}`,
        dataType: "json",
        contentType: "application/json",
        beforeSend: function (request) {
          request.setRequestHeader("token", localStorage.getItem("token"));
        },
        success: function (res) {
          //console.log(res);
          that.picurl = res.data[0].phoUrl;
        },
      });
    },
  },
};
</script>

<style lang="less" scoped>
.goods_pic {
  position: relative;
  width: 100%;
  height: calc((100vw - 50px) / 2);
  max-width: 368px;
  max-height: 368px;
  img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
}
</style>